import bean.Repertory;
import bean.attendance;
import org.apache.commons.dbutils.QueryRunner;
import org.apache.commons.dbutils.handlers.BeanHandler;
import org.apache.commons.dbutils.handlers.BeanListHandler;
import utils.c3p0Utils;

import java.sql.SQLException;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.List;

public class test04 {
    private static QueryRunner qr = new QueryRunner(c3p0Utils.getDataSource());
    public static void main(String[] args) {
        String sql="select COUNT(uid) attendanceNum FROM attendance where DAY(datetime)=?";
        Calendar cal = Calendar.getInstance();
        cal.setTimeInMillis( System.currentTimeMillis());
        attendance at=null;
        int day = cal.get(Calendar.DAY_OF_MONTH) ;
        try {
            at=qr.query(sql,new BeanHandler<attendance>(attendance.class),day);
        } catch (SQLException e) {
            e.printStackTrace();
        }
        System.out.println(at.getAttendanceNum());
    }
}
